from django.db import models


# Create your models here.

class AirData(models.Model):
    status_choices = (
        (0, "待核查"),
        (1, "通过"),
        (2, "不通过")
    )

    date = models.DateField(auto_now=True, verbose_name="日期")
    pm25 = models.IntegerField(verbose_name="pm2.5")
    aqi = models.IntegerField(verbose_name="aqi指数")
    pm10 = models.IntegerField(verbose_name="pm10")
    so2 = models.IntegerField(verbose_name="so2")
    no2 = models.IntegerField(verbose_name="no2")
    o3 = models.IntegerField(verbose_name="o3")
    co = models.FloatField(verbose_name="co")
    city = models.CharField(max_length=255, verbose_name="城市")
    status = models.SmallIntegerField(choices=status_choices, verbose_name="状态", default=0)

    def __str__(self):
        return "{}:-{}".format(self.city, self.date)

    class Meta:
        db_table = "airData"
        verbose_name = "空气质量数据"
        verbose_name_plural = verbose_name


class Warn(models.Model):
    status_choices = (
        (0, "待核查"),
        (1, "通过"),
        (2, "不通过")
    )

    city = models.CharField(max_length=255, verbose_name="城市")
    content = models.TextField(verbose_name="报警描述")
    status = models.SmallIntegerField(choices=status_choices, verbose_name="状态", default=0)

    class Meta:
        verbose_name = "报警查看"
        verbose_name_plural = verbose_name


class Check(models.Model):
    status_choices = (
        (0, "待核查"),
        (1, "通过"),
        (2, "不通过")
    )

    city = models.CharField(max_length=255, verbose_name="城市")
    date = models.DateField(auto_created=True, verbose_name="请求日期")
    status = models.SmallIntegerField(choices=status_choices, verbose_name="状态", default=0)

    class Meta:
        verbose_name = "检查请求"
        verbose_name_plural = verbose_name
